import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:get/get.dart';

class LGetScaffold<T extends GetxController> extends StatelessWidget {
  static double paddingHeight = 0;

  Color? backgroundColor;
  bool? resizeToAvoidBottomInset;
  bool? extendBodyBehindAppBar;
  AppBar? appBar;
  Widget Function() builder;

  LGetScaffold({this.backgroundColor, this.resizeToAvoidBottomInset, this.extendBodyBehindAppBar, required this.builder, this.appBar, super.key});

  @override
  Widget build(BuildContext context) {
    if (paddingHeight == 0 && appBar != null) {
      paddingHeight = MediaQueryData
          .fromWindow(window)
          .padding
          .top + kToolbarHeight;
    }
    var height = appBar == null||(extendBodyBehindAppBar??false) ? Get.height : Get.height - paddingHeight;
    return GetBuilder<T>(
        builder: (l) =>
            Scaffold(
              backgroundColor: backgroundColor,
              resizeToAvoidBottomInset: resizeToAvoidBottomInset ?? false,
              appBar: appBar,
              extendBodyBehindAppBar: extendBodyBehindAppBar?? false,
              body: SingleChildScrollView(
                  child: SizedBox(
                    height: height,
                    child: builder(),
                  )),
            ));
  }
}
